import {useEffect} from 'react'
import menuStore, {EState} from "@/store/menuStore.ts";

const useResize = () => {
    const change = () => {
        if (innerWidth < 780) {
            menuStore.changeCollapsed(true)
        }
        // eslint-disable-next-line @typescript-eslint/no-unused-expressions
        innerWidth < 760 ? menuStore.changeMenuState(EState.dialog) : menuStore.changeMenuState(EState.page)
    }
    useEffect(() => {
        change()
        window.addEventListener('resize', () => {
            change()
        })
    }, [])
}

export default useResize